package com.app.dao.admin;

import com.app.SpringAnnotationDef;
import com.app.dao.BaseDaoImpl;
import com.app.model.ORG_GorupManager;
import com.app.model.ORG_GorupResources;
import com.app.model.User;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: cnprinces
 * Date: 13-1-21
 * Time: 下午4:39
 * To change this template use File | Settings | File Templates.
 */
@Scope(SpringAnnotationDef.SCOPE_PROTOTYPE)
@Repository(SpringAnnotationDef.GORUPMANAGER_DAO)
public class GorupManagerDaoImpl extends BaseDaoImpl<ORG_GorupManager, Integer> implements GorupManagerDao {
    public GorupManagerDaoImpl() {
        super(ORG_GorupManager.class);
    }

    @Override
    public void deleteGorupResources(Integer id) {
        String sql = "delete from  ORG_GorupResources where gorupManagerId=" + id;
        getJdbcTemplate().execute(sql);
    }

    @Override
    public List<ORG_GorupResources> getGorupResources(Integer id) {
        String hql = "from ORG_GorupResources where gorupManagerId=" + id;
        return getSession().createQuery(hql).list();
    }

    @Override
    public List<User> getUserByGorup(Integer id) {
        String hql = "from User where positionId=" + id;
        return getSession().createQuery(hql).list();
    }
}
